from django.apps import AppConfig


class MyappConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'myapp'

    def ready(self):
        # 可以根据实际需求生成不同年份的静态页面
        from .utils import generate_static_html
        from datetime import date
        from .models import ObservationRecord

        current_year = date.today().year
        earliest_record = ObservationRecord.objects.order_by('date').first()
        start_year = earliest_record.date.year if earliest_record else current_year
        year_range = list(range(start_year, current_year + 1))
        for year in year_range:  # 假设数据从2010到2023年
            generate_static_html(year)

